{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "eegpnTbImFUE"
   },
   "source": [
    "# Two-Stages Deep Learning Project\n",
    "\n",
    "<p>This project has been developped by the Montreal Hacknight community. It derives from the braindecode framework and is aimed at being integrable into the Moabb project.</p>\n",
    "\n",
    "<p><ul>https://github.com/robintibor/braindecode</ul>\n",
    "<ul>https://github.com/NeuroTechX/moabb</ul></p>\n",
    "\n",
    "<p>This project wouldn't have been possible without the contribution of these people: Arna (...), Justin (...), Yannick Roy, Eamon Egan, (...) and it is currently being supported by Fred Simard (fs@re-ak.com)</p>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "lBXnRujl24VO"
   },
   "source": [
    "<p>This project consist in deriving a two-stages training process from the brain decode implementation of a Shallow Convolutional Network. The core motivation is to combine the strenghts of deep learning - that is being one of the most powerful ML algorithms out-there - while grinding down it's fall back - it requires an immense of data.</p>\n",
    "\n",
    "<p>The goal is to develop a method to train the network in two stages:</p>\n",
    "<p><ul>1) Train the network over a large dataset, this training forms some kind of prior over the network</ul>\n",
    "<ul>2) Train the network a second time, this time on the dataset of interest</ul>\n",
    "</p>\n",
    "\n",
    "<p>The premise motivating this approach is that the second training is likely to proceed faster than what is normally required to train a deep net, without sacrificing the performance; and, we suspect that the second training will be able to exploit the specificities of the dataset of interest in a way to surpasses the first training, which was trained on a generalistic dataset.</p>"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 136
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 13530,
     "status": "ok",
     "timestamp": 1544140279544,
     "user": {
      "displayName": "TheAtom2626",
      "photoUrl": "",
      "userId": "00378881698832173059"
     },
     "user_tz": 300
    },
    "id": "4ci1qeJ39mY9",
    "outputId": "e7694d42-30cf-4cf4-8ca5-13f17972638a"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Cloning into 'dl-eeg-playground'...\n",
      "remote: Enumerating objects: 25, done.\u001b[K\n",
      "remote: Counting objects: 100% (25/25), done.\u001b[K\n",
      "remote: Compressing objects: 100% (12/12), done.\u001b[K\n",
      "remote: Total 286 (delta 13), reused 22 (delta 12), pack-reused 261\u001b[K\n",
      "Receiving objects: 100% (286/286), 1.97 MiB | 2.15 MiB/s, done.\n",
      "Resolving deltas: 100% (141/141), done.\n"
     ]
    }
   ],
   "source": [
    "\"\"\"\n",
    "#\n",
    "# Download the github, which contains the package with the networks\n",
    "#\n",
    "\"\"\"\n",
    "\n",
    "# reset to default base path\n",
    "import os\n",
    "os.chdir('/content/')\n",
    "\n",
    "# if dl-eeg-playground already here, erase\n",
    "!rm -rf dl-eeg-playground\n",
    "\n",
    "# clone dl-eeg-playground and cd to it\n",
    "!git clone https://github.com/NeuroTechX/dl-eeg-playground.git \n",
    "os.chdir('dl-eeg-playground/brainDecode/towardMoabbIntegration')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 7721
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 458966,
     "status": "ok",
     "timestamp": 1544140726686,
     "user": {
      "displayName": "TheAtom2626",
      "photoUrl": "",
      "userId": "00378881698832173059"
     },
     "user_tz": 300
    },
    "id": "NSi52lWjPNN4",
    "outputId": "1e0331cb-d3c1-4cc2-fe1c-1f3f9da83396"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--2018-12-06 23:51:20--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S01T.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S01T.mat [following]\n",
      "--2018-12-06 23:51:20--  https://lampx.tugraz.at/~bci/database/002-2014/S01T.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 39794870 (38M)\n",
      "Saving to: ‘S01T.mat’\n",
      "\n",
      "S01T.mat            100%[===================>]  37.95M  6.83MB/s    in 11s     \n",
      "\n",
      "2018-12-06 23:51:33 (3.41 MB/s) - ‘S01T.mat’ saved [39794870/39794870]\n",
      "\n",
      "--2018-12-06 23:51:34--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S01E.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S01E.mat [following]\n",
      "--2018-12-06 23:51:35--  https://lampx.tugraz.at/~bci/database/002-2014/S01E.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 23769588 (23M)\n",
      "Saving to: ‘S01E.mat’\n",
      "\n",
      "S01E.mat            100%[===================>]  22.67M  3.98MB/s    in 10s     \n",
      "\n",
      "2018-12-06 23:51:46 (2.27 MB/s) - ‘S01E.mat’ saved [23769588/23769588]\n",
      "\n",
      "--2018-12-06 23:51:47--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S02T.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S02T.mat [following]\n",
      "--2018-12-06 23:51:47--  https://lampx.tugraz.at/~bci/database/002-2014/S02T.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 38364523 (37M)\n",
      "Saving to: ‘S02T.mat’\n",
      "\n",
      "S02T.mat            100%[===================>]  36.59M  7.04MB/s    in 10s     \n",
      "\n",
      "2018-12-06 23:51:59 (3.60 MB/s) - ‘S02T.mat’ saved [38364523/38364523]\n",
      "\n",
      "--2018-12-06 23:52:00--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S02E.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S02E.mat [following]\n",
      "--2018-12-06 23:52:00--  https://lampx.tugraz.at/~bci/database/002-2014/S02E.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 22998442 (22M)\n",
      "Saving to: ‘S02E.mat’\n",
      "\n",
      "S02E.mat            100%[===================>]  21.93M  3.82MB/s    in 8.7s    \n",
      "\n",
      "2018-12-06 23:52:10 (2.52 MB/s) - ‘S02E.mat’ saved [22998442/22998442]\n",
      "\n",
      "--2018-12-06 23:52:11--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S03T.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S03T.mat [following]\n",
      "--2018-12-06 23:52:11--  https://lampx.tugraz.at/~bci/database/002-2014/S03T.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 39739945 (38M)\n",
      "Saving to: ‘S03T.mat’\n",
      "\n",
      "S03T.mat            100%[===================>]  37.90M  7.44MB/s    in 11s     \n",
      "\n",
      "2018-12-06 23:52:23 (3.51 MB/s) - ‘S03T.mat’ saved [39739945/39739945]\n",
      "\n",
      "--2018-12-06 23:52:25--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S03E.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S03E.mat [following]\n",
      "--2018-12-06 23:52:25--  https://lampx.tugraz.at/~bci/database/002-2014/S03E.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 23797275 (23M)\n",
      "Saving to: ‘S03E.mat’\n",
      "\n",
      "S03E.mat            100%[===================>]  22.69M  3.86MB/s    in 9.7s    \n",
      "\n",
      "2018-12-06 23:52:36 (2.34 MB/s) - ‘S03E.mat’ saved [23797275/23797275]\n",
      "\n",
      "--2018-12-06 23:52:37--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S04T.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S04T.mat [following]\n",
      "--2018-12-06 23:52:37--  https://lampx.tugraz.at/~bci/database/002-2014/S04T.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 39607931 (38M)\n",
      "Saving to: ‘S04T.mat’\n",
      "\n",
      "S04T.mat            100%[===================>]  37.77M  7.19MB/s    in 10s     \n",
      "\n",
      "2018-12-06 23:52:48 (3.79 MB/s) - ‘S04T.mat’ saved [39607931/39607931]\n",
      "\n",
      "--2018-12-06 23:52:50--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S04E.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S04E.mat [following]\n",
      "--2018-12-06 23:52:50--  https://lampx.tugraz.at/~bci/database/002-2014/S04E.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 23752764 (23M)\n",
      "Saving to: ‘S04E.mat’\n",
      "\n",
      "S04E.mat            100%[===================>]  22.65M  3.88MB/s    in 8.8s    \n",
      "\n",
      "2018-12-06 23:53:00 (2.56 MB/s) - ‘S04E.mat’ saved [23752764/23752764]\n",
      "\n",
      "--2018-12-06 23:53:01--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S05T.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S05T.mat [following]\n",
      "--2018-12-06 23:53:02--  https://lampx.tugraz.at/~bci/database/002-2014/S05T.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 39091212 (37M)\n",
      "Saving to: ‘S05T.mat’\n",
      "\n",
      "S05T.mat            100%[===================>]  37.28M  7.07MB/s    in 11s     \n",
      "\n",
      "2018-12-06 23:53:13 (3.54 MB/s) - ‘S05T.mat’ saved [39091212/39091212]\n",
      "\n",
      "--2018-12-06 23:53:14--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S05E.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S05E.mat [following]\n",
      "--2018-12-06 23:53:15--  https://lampx.tugraz.at/~bci/database/002-2014/S05E.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 23628634 (23M)\n",
      "Saving to: ‘S05E.mat’\n",
      "\n",
      "S05E.mat            100%[===================>]  22.53M  3.85MB/s    in 10s     \n",
      "\n",
      "2018-12-06 23:53:26 (2.22 MB/s) - ‘S05E.mat’ saved [23628634/23628634]\n",
      "\n",
      "--2018-12-06 23:53:27--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S06T.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S06T.mat [following]\n",
      "--2018-12-06 23:53:27--  https://lampx.tugraz.at/~bci/database/002-2014/S06T.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 40027626 (38M)\n",
      "Saving to: ‘S06T.mat’\n",
      "\n",
      "S06T.mat            100%[===================>]  38.17M  8.20MB/s    in 11s     \n",
      "\n",
      "2018-12-06 23:53:40 (3.38 MB/s) - ‘S06T.mat’ saved [40027626/40027626]\n",
      "\n",
      "--2018-12-06 23:53:42--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S06E.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S06E.mat [following]\n",
      "--2018-12-06 23:53:43--  https://lampx.tugraz.at/~bci/database/002-2014/S06E.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 23850651 (23M)\n",
      "Saving to: ‘S06E.mat’\n",
      "\n",
      "S06E.mat            100%[===================>]  22.75M  3.90MB/s    in 9.5s    \n",
      "\n",
      "2018-12-06 23:53:53 (2.39 MB/s) - ‘S06E.mat’ saved [23850651/23850651]\n",
      "\n",
      "--2018-12-06 23:53:54--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S07T.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S07T.mat [following]\n",
      "--2018-12-06 23:53:55--  https://lampx.tugraz.at/~bci/database/002-2014/S07T.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 40261257 (38M)\n",
      "Saving to: ‘S07T.mat’\n",
      "\n",
      "S07T.mat            100%[===================>]  38.40M  7.25MB/s    in 11s     \n",
      "\n",
      "2018-12-06 23:54:06 (3.63 MB/s) - ‘S07T.mat’ saved [40261257/40261257]\n",
      "\n",
      "--2018-12-06 23:54:07--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S07E.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S07E.mat [following]\n",
      "--2018-12-06 23:54:08--  https://lampx.tugraz.at/~bci/database/002-2014/S07E.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 23997847 (23M)\n",
      "Saving to: ‘S07E.mat’\n",
      "\n",
      "S07E.mat            100%[===================>]  22.89M  3.89MB/s    in 9.7s    \n",
      "\n",
      "2018-12-06 23:54:19 (2.36 MB/s) - ‘S07E.mat’ saved [23997847/23997847]\n",
      "\n",
      "--2018-12-06 23:54:20--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S08T.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S08T.mat [following]\n",
      "--2018-12-06 23:54:20--  https://lampx.tugraz.at/~bci/database/002-2014/S08T.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 39735612 (38M)\n",
      "Saving to: ‘S08T.mat’\n",
      "\n",
      "S08T.mat            100%[===================>]  37.89M  5.59MB/s    in 13s     \n",
      "\n",
      "2018-12-06 23:54:34 (2.99 MB/s) - ‘S08T.mat’ saved [39735612/39735612]\n",
      "\n",
      "--2018-12-06 23:54:35--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S08E.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S08E.mat [following]\n",
      "--2018-12-06 23:54:35--  https://lampx.tugraz.at/~bci/database/002-2014/S08E.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 23791571 (23M)\n",
      "Saving to: ‘S08E.mat’\n",
      "\n",
      "S08E.mat            100%[===================>]  22.69M  3.96MB/s    in 9.5s    \n",
      "\n",
      "2018-12-06 23:54:46 (2.40 MB/s) - ‘S08E.mat’ saved [23791571/23791571]\n",
      "\n",
      "--2018-12-06 23:54:47--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S09T.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S09T.mat [following]\n",
      "--2018-12-06 23:54:47--  https://lampx.tugraz.at/~bci/database/002-2014/S09T.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 39805150 (38M)\n",
      "Saving to: ‘S09T.mat’\n",
      "\n",
      "S09T.mat            100%[===================>]  37.96M  7.31MB/s    in 11s     \n",
      "\n",
      "2018-12-06 23:54:59 (3.46 MB/s) - ‘S09T.mat’ saved [39805150/39805150]\n",
      "\n",
      "--2018-12-06 23:55:00--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S09E.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S09E.mat [following]\n",
      "--2018-12-06 23:55:01--  https://lampx.tugraz.at/~bci/database/002-2014/S09E.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 23610622 (23M)\n",
      "Saving to: ‘S09E.mat’\n",
      "\n",
      "S09E.mat            100%[===================>]  22.52M  3.96MB/s    in 9.4s    \n",
      "\n",
      "2018-12-06 23:55:11 (2.39 MB/s) - ‘S09E.mat’ saved [23610622/23610622]\n",
      "\n",
      "--2018-12-06 23:55:12--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S10T.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S10T.mat [following]\n",
      "--2018-12-06 23:55:13--  https://lampx.tugraz.at/~bci/database/002-2014/S10T.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 39871971 (38M)\n",
      "Saving to: ‘S10T.mat’\n",
      "\n",
      "S10T.mat            100%[===================>]  38.02M  3.44MB/s    in 17s     \n",
      "\n",
      "2018-12-06 23:55:31 (2.22 MB/s) - ‘S10T.mat’ saved [39871971/39871971]\n",
      "\n",
      "--2018-12-06 23:55:32--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S10E.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S10E.mat [following]\n",
      "--2018-12-06 23:55:32--  https://lampx.tugraz.at/~bci/database/002-2014/S10E.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 23750112 (23M)\n",
      "Saving to: ‘S10E.mat’\n",
      "\n",
      "S10E.mat            100%[===================>]  22.65M  3.88MB/s    in 9.4s    \n",
      "\n",
      "2018-12-06 23:55:43 (2.42 MB/s) - ‘S10E.mat’ saved [23750112/23750112]\n",
      "\n",
      "--2018-12-06 23:55:43--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S11T.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S11T.mat [following]\n",
      "--2018-12-06 23:55:44--  https://lampx.tugraz.at/~bci/database/002-2014/S11T.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 40140184 (38M)\n",
      "Saving to: ‘S11T.mat’\n",
      "\n",
      "S11T.mat            100%[===================>]  38.28M  3.33MB/s    in 24s     \n",
      "\n",
      "2018-12-06 23:56:09 (1.58 MB/s) - ‘S11T.mat’ saved [40140184/40140184]\n",
      "\n",
      "--2018-12-06 23:56:10--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S11E.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S11E.mat [following]\n",
      "--2018-12-06 23:56:11--  https://lampx.tugraz.at/~bci/database/002-2014/S11E.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 24171700 (23M)\n",
      "Saving to: ‘S11E.mat’\n",
      "\n",
      "S11E.mat            100%[===================>]  23.05M  3.95MB/s    in 10s     \n",
      "\n",
      "2018-12-06 23:56:22 (2.23 MB/s) - ‘S11E.mat’ saved [24171700/24171700]\n",
      "\n",
      "--2018-12-06 23:56:23--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S12T.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S12T.mat [following]\n",
      "--2018-12-06 23:56:24--  https://lampx.tugraz.at/~bci/database/002-2014/S12T.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 40093093 (38M)\n",
      "Saving to: ‘S12T.mat’\n",
      "\n",
      "S12T.mat            100%[===================>]  38.24M  7.46MB/s    in 11s     \n",
      "\n",
      "2018-12-06 23:56:35 (3.60 MB/s) - ‘S12T.mat’ saved [40093093/40093093]\n",
      "\n",
      "--2018-12-06 23:56:36--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S12E.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S12E.mat [following]\n",
      "--2018-12-06 23:56:37--  https://lampx.tugraz.at/~bci/database/002-2014/S12E.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 23905075 (23M)\n",
      "Saving to: ‘S12E.mat’\n",
      "\n",
      "S12E.mat            100%[===================>]  22.80M  3.92MB/s    in 10s     \n",
      "\n",
      "2018-12-06 23:56:48 (2.26 MB/s) - ‘S12E.mat’ saved [23905075/23905075]\n",
      "\n",
      "--2018-12-06 23:56:49--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S13T.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S13T.mat [following]\n",
      "--2018-12-06 23:56:49--  https://lampx.tugraz.at/~bci/database/002-2014/S13T.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 39819174 (38M)\n",
      "Saving to: ‘S13T.mat’\n",
      "\n",
      "S13T.mat            100%[===================>]  37.97M  7.05MB/s    in 11s     \n",
      "\n",
      "2018-12-06 23:57:01 (3.57 MB/s) - ‘S13T.mat’ saved [39819174/39819174]\n",
      "\n",
      "--2018-12-06 23:57:02--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S13E.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S13E.mat [following]\n",
      "--2018-12-06 23:57:02--  https://lampx.tugraz.at/~bci/database/002-2014/S13E.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 23669359 (23M)\n",
      "Saving to: ‘S13E.mat’\n",
      "\n",
      "S13E.mat            100%[===================>]  22.57M  3.94MB/s    in 9.7s    \n",
      "\n",
      "2018-12-06 23:57:13 (2.33 MB/s) - ‘S13E.mat’ saved [23669359/23669359]\n",
      "\n",
      "--2018-12-06 23:57:14--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S14T.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S14T.mat [following]\n",
      "--2018-12-06 23:57:15--  https://lampx.tugraz.at/~bci/database/002-2014/S14T.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 39859134 (38M)\n",
      "Saving to: ‘S14T.mat’\n",
      "\n",
      "S14T.mat            100%[===================>]  38.01M  6.97MB/s    in 12s     \n",
      "\n",
      "2018-12-06 23:57:28 (3.25 MB/s) - ‘S14T.mat’ saved [39859134/39859134]\n",
      "\n",
      "--2018-12-06 23:57:29--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S14E.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S14E.mat [following]\n",
      "--2018-12-06 23:57:29--  https://lampx.tugraz.at/~bci/database/002-2014/S14E.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 23970887 (23M)\n",
      "Saving to: ‘S14E.mat’\n",
      "\n",
      "S14E.mat            100%[===================>]  22.86M  3.95MB/s    in 9.3s    \n",
      "\n",
      "2018-12-06 23:57:40 (2.46 MB/s) - ‘S14E.mat’ saved [23970887/23970887]\n",
      "\n",
      "tcmalloc: large alloc 1073750016 bytes == 0x5bf96000 @  0x7f2fcd6b42a4 0x591a07 0x5b5d56 0x502e9a 0x506859 0x502209 0x502f3d 0x506859 0x504c28 0x502540 0x502f3d 0x506859 0x504c28 0x502540 0x502f3d 0x506859 0x504c28 0x502540 0x502f3d 0x507641 0x502209 0x502f3d 0x506859 0x504c28 0x502540 0x502f3d 0x507641 0x504c28 0x502540 0x502f3d 0x507641\n",
      "\n",
      "(2240, 15, 3584)\n",
      "(2240,)\n"
     ]
    }
   ],
   "source": [
    "#\n",
    "# Download the whole BNCI 002-2014 dataset\n",
    "#\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S01T.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S01E.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S02T.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S02E.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S03T.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S03E.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S04T.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S04E.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S05T.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S05E.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S06T.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S06E.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S07T.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S07E.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S08T.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S08E.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S09T.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S09E.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S10T.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S10E.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S11T.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S11E.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S12T.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S12E.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S13T.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S13E.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S14T.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S14E.mat\n",
    "\n",
    "# move files into a dedicated folder\n",
    "!mkdir BBCIData\n",
    "!mv *.mat BBCIData\n",
    "\n",
    "#install brain decode\n",
    "!pip install braindecode -q\n",
    "\n",
    "# install pytorch\n",
    "# ref: http://pytorch.org/\n",
    "from os import path\n",
    "from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag\n",
    "platform = '{}{}-{}'.format(get_abbr_impl(), get_impl_ver(), get_abi_tag())\n",
    "\n",
    "accelerator = 'cu80' if path.exists('/opt/bin/nvidia-smi') else 'cpu'\n",
    "\n",
    "#!pip install -q http://download.pytorch.org/whl/{accelerator}/torch-0.3.0.post4-{platform}-linux_x86_64.whl torchvision\n",
    "!pip install -q http://download.pytorch.org/whl/{accelerator}/torch-0.4.0-{platform}-linux_x86_64.whl torchvision\n",
    "#  cu91/torch-0.4.0-cp36-cp36m-linux_x86_64.whl\n",
    "import torch\n",
    "\n",
    "import scipy.io as sio\n",
    "import numpy as np\n",
    "from os import listdir\n",
    "from os.path import isfile, join\n",
    "\n",
    "# prepare data containers\n",
    "y = []\n",
    "X = []\n",
    "\n",
    "\"\"\"\n",
    "Now, let's load data.\n",
    "\n",
    "We read the file for the desired subject, and parse the data to extract:\n",
    "- samplingRate\n",
    "- trialLength\n",
    "- X, a M x N x K matrix, which stands for trial x chan x samples\n",
    "    - the actual values are 160 x 15 x 2560\n",
    "- y, a M vector containing the labels {0,1}\n",
    "\n",
    "ref: Dataset description: https://lampx.tugraz.at/~bci/database/002-2014/description.pdf\n",
    "\"\"\"\n",
    "\n",
    "folder = \"BBCIData\"\n",
    "\n",
    "allDatasets = listdir(folder)\n",
    "    \n",
    "for f in listdir(folder):\n",
    "    # read file\n",
    "    d1T = sio.loadmat(folder + \"/\" + f)\n",
    "    \n",
    "    samplingRate = d1T['data'][0][0][0][0][3][0][0]\n",
    "    trialLength = 7*samplingRate\n",
    "\n",
    "    # run through all training runs\n",
    "    for run in range(len(d1T['data'][0])):\n",
    "        y.append(d1T['data'][0][run][0][0][2][0]) # labels\n",
    "        timestamps = d1T['data'][0][run][0][0][1][0] # timestamps\n",
    "        rawData = d1T['data'][0][run][0][0][0].transpose() # chan x data\n",
    "\n",
    "        # parse out data based on timestamps\n",
    "        for start in timestamps:\n",
    "            end = start + trialLength\n",
    "            X.append(rawData[:,start:end]) #15 x 2560\n",
    "\n",
    "    del rawData\n",
    "    del d1T\n",
    "\n",
    "# arrange data into num7py arrays\n",
    "# also torch expect float32 for samples\n",
    "# and int64 for labels {0,1}\n",
    "X = np.array(X).astype(np.float32)\n",
    "y = (np.array(y).flatten()-1).astype(np.int64)\n",
    "print()\n",
    "print(X.shape)\n",
    "print(y.shape)\n",
    "\n",
    "\n",
    "# rand permute dataset\n",
    "idx = np.random.permutation(X.shape[0])\n",
    "\n",
    "X = X[idx,:,:]\n",
    "y = y[idx]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 5168
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 257584,
     "status": "ok",
     "timestamp": 1544141654502,
     "user": {
      "displayName": "TheAtom2626",
      "photoUrl": "",
      "userId": "00378881698832173059"
     },
     "user_tz": 300
    },
    "id": "6PUAO5bSPfN3",
    "outputId": "3ea68044-ddfd-4de8-b6b7-f08939a490f3"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 0\n",
      "Train  Loss: 2.08115\n",
      "Train  Accuracy: 49.6%\n",
      "Test   Loss: 2.04731\n",
      "Test   Accuracy: 52.1%\n",
      "Epoch 1\n",
      "Train  Loss: 0.75969\n",
      "Train  Accuracy: 50.4%\n",
      "Test   Loss: 0.75388\n",
      "Test   Accuracy: 53.2%\n",
      "Epoch 2\n",
      "Train  Loss: 1.25856\n",
      "Train  Accuracy: 49.6%\n",
      "Test   Loss: 1.23456\n",
      "Test   Accuracy: 52.1%\n",
      "Epoch 3\n",
      "Train  Loss: 0.70035\n",
      "Train  Accuracy: 56.2%\n",
      "Test   Loss: 0.72591\n",
      "Test   Accuracy: 53.9%\n",
      "Epoch 4\n",
      "Train  Loss: 0.69096\n",
      "Train  Accuracy: 55.5%\n",
      "Test   Loss: 0.72498\n",
      "Test   Accuracy: 51.1%\n",
      "Epoch 5\n",
      "Train  Loss: 0.67922\n",
      "Train  Accuracy: 56.9%\n",
      "Test   Loss: 0.72395\n",
      "Test   Accuracy: 52.5%\n",
      "Epoch 6\n",
      "Train  Loss: 0.68005\n",
      "Train  Accuracy: 56.7%\n",
      "Test   Loss: 0.72818\n",
      "Test   Accuracy: 50.4%\n",
      "Epoch 7\n",
      "Train  Loss: 0.66926\n",
      "Train  Accuracy: 58.4%\n",
      "Test   Loss: 0.70863\n",
      "Test   Accuracy: 52.9%\n",
      "Epoch 8\n",
      "Train  Loss: 0.65986\n",
      "Train  Accuracy: 60.5%\n",
      "Test   Loss: 0.69376\n",
      "Test   Accuracy: 50.7%\n",
      "Epoch 9\n",
      "Train  Loss: 0.65886\n",
      "Train  Accuracy: 60.8%\n",
      "Test   Loss: 0.70577\n",
      "Test   Accuracy: 50.7%\n",
      "Epoch 10\n",
      "Train  Loss: 0.73277\n",
      "Train  Accuracy: 52.5%\n",
      "Test   Loss: 0.80172\n",
      "Test   Accuracy: 48.9%\n",
      "Epoch 11\n",
      "Train  Loss: 0.68138\n",
      "Train  Accuracy: 57.2%\n",
      "Test   Loss: 0.73720\n",
      "Test   Accuracy: 52.1%\n",
      "Epoch 12\n",
      "Train  Loss: 0.72220\n",
      "Train  Accuracy: 53.3%\n",
      "Test   Loss: 0.75291\n",
      "Test   Accuracy: 51.8%\n",
      "Epoch 13\n",
      "Train  Loss: 0.60971\n",
      "Train  Accuracy: 66.5%\n",
      "Test   Loss: 0.66757\n",
      "Test   Accuracy: 58.6%\n",
      "Epoch 14\n",
      "Train  Loss: 0.58040\n",
      "Train  Accuracy: 69.1%\n",
      "Test   Loss: 0.63830\n",
      "Test   Accuracy: 63.6%\n",
      "Epoch 15\n",
      "Train  Loss: 0.79680\n",
      "Train  Accuracy: 58.9%\n",
      "Test   Loss: 0.88658\n",
      "Test   Accuracy: 55.7%\n",
      "Epoch 16\n",
      "Train  Loss: 0.54808\n",
      "Train  Accuracy: 71.7%\n",
      "Test   Loss: 0.60998\n",
      "Test   Accuracy: 66.1%\n",
      "Epoch 17\n",
      "Train  Loss: 0.54252\n",
      "Train  Accuracy: 71.9%\n",
      "Test   Loss: 0.60957\n",
      "Test   Accuracy: 66.4%\n",
      "Epoch 18\n",
      "Train  Loss: 0.51975\n",
      "Train  Accuracy: 74.1%\n",
      "Test   Loss: 0.58788\n",
      "Test   Accuracy: 66.8%\n",
      "Epoch 19\n",
      "Train  Loss: 0.59082\n",
      "Train  Accuracy: 65.0%\n",
      "Test   Loss: 0.65070\n",
      "Test   Accuracy: 60.7%\n",
      "Epoch 20\n",
      "Train  Loss: 0.60372\n",
      "Train  Accuracy: 64.6%\n",
      "Test   Loss: 0.65467\n",
      "Test   Accuracy: 62.9%\n",
      "Epoch 21\n",
      "Train  Loss: 0.50760\n",
      "Train  Accuracy: 74.5%\n",
      "Test   Loss: 0.58017\n",
      "Test   Accuracy: 70.7%\n",
      "Epoch 22\n",
      "Train  Loss: 0.51147\n",
      "Train  Accuracy: 73.1%\n",
      "Test   Loss: 0.58066\n",
      "Test   Accuracy: 67.5%\n",
      "Epoch 23\n",
      "Train  Loss: 0.48559\n",
      "Train  Accuracy: 77.7%\n",
      "Test   Loss: 0.58163\n",
      "Test   Accuracy: 69.3%\n",
      "Epoch 24\n",
      "Train  Loss: 0.47749\n",
      "Train  Accuracy: 77.8%\n",
      "Test   Loss: 0.56588\n",
      "Test   Accuracy: 70.0%\n",
      "Epoch 25\n",
      "Train  Loss: 0.52517\n",
      "Train  Accuracy: 72.2%\n",
      "Test   Loss: 0.62275\n",
      "Test   Accuracy: 64.6%\n",
      "Epoch 26\n",
      "Train  Loss: 0.47597\n",
      "Train  Accuracy: 77.8%\n",
      "Test   Loss: 0.57183\n",
      "Test   Accuracy: 69.3%\n",
      "Epoch 27\n",
      "Train  Loss: 1.09261\n",
      "Train  Accuracy: 60.1%\n",
      "Test   Loss: 1.26858\n",
      "Test   Accuracy: 55.0%\n",
      "Epoch 28\n",
      "Train  Loss: 0.47144\n",
      "Train  Accuracy: 78.5%\n",
      "Test   Loss: 0.59414\n",
      "Test   Accuracy: 67.1%\n",
      "Epoch 29\n",
      "Train  Loss: 0.46306\n",
      "Train  Accuracy: 78.4%\n",
      "Test   Loss: 0.57667\n",
      "Test   Accuracy: 69.3%\n",
      "Epoch 30\n",
      "Train  Loss: 0.45248\n",
      "Train  Accuracy: 79.9%\n",
      "Test   Loss: 0.58262\n",
      "Test   Accuracy: 68.6%\n",
      "Epoch 31\n",
      "Train  Loss: 0.77807\n",
      "Train  Accuracy: 65.4%\n",
      "Test   Loss: 0.92063\n",
      "Test   Accuracy: 61.4%\n",
      "Epoch 32\n",
      "Train  Loss: 0.47432\n",
      "Train  Accuracy: 75.5%\n",
      "Test   Loss: 0.57162\n",
      "Test   Accuracy: 70.0%\n",
      "Epoch 33\n",
      "Train  Loss: 0.46333\n",
      "Train  Accuracy: 77.9%\n",
      "Test   Loss: 0.58067\n",
      "Test   Accuracy: 69.6%\n",
      "Epoch 34\n",
      "Train  Loss: 0.44035\n",
      "Train  Accuracy: 80.1%\n",
      "Test   Loss: 0.58571\n",
      "Test   Accuracy: 68.9%\n",
      "Epoch 35\n",
      "Train  Loss: 0.45210\n",
      "Train  Accuracy: 79.2%\n",
      "Test   Loss: 0.56440\n",
      "Test   Accuracy: 70.4%\n",
      "Epoch 36\n",
      "Train  Loss: 0.49392\n",
      "Train  Accuracy: 74.8%\n",
      "Test   Loss: 0.59989\n",
      "Test   Accuracy: 68.6%\n",
      "Epoch 37\n",
      "Train  Loss: 0.51339\n",
      "Train  Accuracy: 74.3%\n",
      "Test   Loss: 0.63082\n",
      "Test   Accuracy: 68.6%\n",
      "Epoch 38\n",
      "Train  Loss: 0.43237\n",
      "Train  Accuracy: 80.3%\n",
      "Test   Loss: 0.56310\n",
      "Test   Accuracy: 68.9%\n",
      "Epoch 39\n",
      "Train  Loss: 0.43999\n",
      "Train  Accuracy: 80.1%\n",
      "Test   Loss: 0.55284\n",
      "Test   Accuracy: 70.7%\n",
      "Epoch 40\n",
      "Train  Loss: 0.50042\n",
      "Train  Accuracy: 74.8%\n",
      "Test   Loss: 0.59341\n",
      "Test   Accuracy: 70.7%\n",
      "Epoch 41\n",
      "Train  Loss: 0.71897\n",
      "Train  Accuracy: 61.5%\n",
      "Test   Loss: 0.81649\n",
      "Test   Accuracy: 59.6%\n",
      "Epoch 42\n",
      "Train  Loss: 0.47271\n",
      "Train  Accuracy: 75.2%\n",
      "Test   Loss: 0.56315\n",
      "Test   Accuracy: 70.4%\n",
      "Epoch 43\n",
      "Train  Loss: 0.41700\n",
      "Train  Accuracy: 81.6%\n",
      "Test   Loss: 0.55485\n",
      "Test   Accuracy: 72.5%\n",
      "Epoch 44\n",
      "Train  Loss: 0.84395\n",
      "Train  Accuracy: 58.4%\n",
      "Test   Loss: 0.91747\n",
      "Test   Accuracy: 56.8%\n",
      "Epoch 45\n",
      "Train  Loss: 0.42418\n",
      "Train  Accuracy: 80.1%\n",
      "Test   Loss: 0.56180\n",
      "Test   Accuracy: 70.0%\n",
      "Epoch 46\n",
      "Train  Loss: 0.41274\n",
      "Train  Accuracy: 81.2%\n",
      "Test   Loss: 0.54673\n",
      "Test   Accuracy: 68.9%\n",
      "Epoch 47\n",
      "Train  Loss: 0.83730\n",
      "Train  Accuracy: 57.0%\n",
      "Test   Loss: 0.87217\n",
      "Test   Accuracy: 57.1%\n",
      "Epoch 48\n",
      "Train  Loss: 0.44743\n",
      "Train  Accuracy: 77.1%\n",
      "Test   Loss: 0.55114\n",
      "Test   Accuracy: 71.8%\n",
      "Epoch 49\n",
      "Train  Loss: 0.41979\n",
      "Train  Accuracy: 80.4%\n",
      "Test   Loss: 0.57880\n",
      "Test   Accuracy: 68.2%\n",
      "Epoch 50\n",
      "Train  Loss: 0.40166\n",
      "Train  Accuracy: 82.7%\n",
      "Test   Loss: 0.55398\n",
      "Test   Accuracy: 71.1%\n",
      "Epoch 51\n",
      "Train  Loss: 0.85434\n",
      "Train  Accuracy: 59.0%\n",
      "Test   Loss: 0.95994\n",
      "Test   Accuracy: 57.1%\n",
      "Epoch 52\n",
      "Train  Loss: 0.42632\n",
      "Train  Accuracy: 80.4%\n",
      "Test   Loss: 0.57108\n",
      "Test   Accuracy: 71.4%\n",
      "Epoch 53\n",
      "Train  Loss: 0.99225\n",
      "Train  Accuracy: 55.3%\n",
      "Test   Loss: 1.05140\n",
      "Test   Accuracy: 55.4%\n",
      "Epoch 54\n",
      "Train  Loss: 0.40169\n",
      "Train  Accuracy: 81.6%\n",
      "Test   Loss: 0.56904\n",
      "Test   Accuracy: 68.2%\n",
      "Epoch 55\n",
      "Train  Loss: 0.39920\n",
      "Train  Accuracy: 82.2%\n",
      "Test   Loss: 0.59583\n",
      "Test   Accuracy: 69.6%\n",
      "Epoch 56\n",
      "Train  Loss: 0.51478\n",
      "Train  Accuracy: 71.3%\n",
      "Test   Loss: 0.65656\n",
      "Test   Accuracy: 65.4%\n",
      "Epoch 57\n",
      "Train  Loss: 0.39562\n",
      "Train  Accuracy: 82.7%\n",
      "Test   Loss: 0.60420\n",
      "Test   Accuracy: 68.9%\n",
      "Epoch 58\n",
      "Train  Loss: 0.45859\n",
      "Train  Accuracy: 76.2%\n",
      "Test   Loss: 0.59354\n",
      "Test   Accuracy: 70.0%\n",
      "Epoch 59\n",
      "Train  Loss: 0.53055\n",
      "Train  Accuracy: 70.7%\n",
      "Test   Loss: 0.69716\n",
      "Test   Accuracy: 64.6%\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "ShallowFBCSPNet_GeneralTrainer(filter_time_length=75, n_filters_spat=5,\n",
       "                n_filters_time=10, nb_epoch=60, pool_time_length=60,\n",
       "                pool_time_stride=30)"
      ]
     },
     "execution_count": 8,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "# load the general network Trainer\n",
    "from brainDecodeSKLearnWrapper.ShallowFBCSPNet_GeneralTrainer import ShallowFBCSPNet_GeneralTrainer\n",
    "\n",
    "classifier = ShallowFBCSPNet_GeneralTrainer(nb_epoch=60)\n",
    "classifier.fit(X,y)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "OdkIjcgr1qmh"
   },
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 34
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 215,
     "status": "ok",
     "timestamp": 1542934354077,
     "user": {
      "displayName": "TheAtom2626",
      "photoUrl": "",
      "userId": "00378881698832173059"
     },
     "user_tz": 300
    },
    "id": "S1xGwZjcAz4b",
    "outputId": "053ae4a5-0f2c-4b0e-d75b-44734a7feaf6"
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<generator object Module.parameters at 0x7fa40a6c1990>"
      ]
     },
     "execution_count": 9,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "classifier.model.parameters()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 4267
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 224673,
     "status": "ok",
     "timestamp": 1542935923419,
     "user": {
      "displayName": "TheAtom2626",
      "photoUrl": "",
      "userId": "00378881698832173059"
     },
     "user_tz": 300
    },
    "id": "bkXIatn-2lxV",
    "outputId": "9844cdda-5f0c-49da-fd59-4adb5aac0412"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 0\n",
      "Train  Loss: 0.45825\n",
      "Train  Accuracy: 79.7%\n",
      "Test   Loss: 0.48396\n",
      "Test   Accuracy: 76.4%\n",
      "Epoch 1\n",
      "Train  Loss: 0.43202\n",
      "Train  Accuracy: 78.1%\n",
      "Test   Loss: 0.49042\n",
      "Test   Accuracy: 75.0%\n",
      "Epoch 2\n",
      "Train  Loss: 0.42766\n",
      "Train  Accuracy: 77.3%\n",
      "Test   Loss: 0.50944\n",
      "Test   Accuracy: 72.9%\n",
      "Epoch 3\n",
      "Train  Loss: 0.67299\n",
      "Train  Accuracy: 64.4%\n",
      "Test   Loss: 0.79049\n",
      "Test   Accuracy: 57.9%\n",
      "Epoch 4\n",
      "Train  Loss: 0.34711\n",
      "Train  Accuracy: 86.8%\n",
      "Test   Loss: 0.43078\n",
      "Test   Accuracy: 79.3%\n",
      "Epoch 5\n",
      "Train  Loss: 0.85764\n",
      "Train  Accuracy: 59.7%\n",
      "Test   Loss: 0.98398\n",
      "Test   Accuracy: 55.0%\n",
      "Epoch 6\n",
      "Train  Loss: 0.73597\n",
      "Train  Accuracy: 63.9%\n",
      "Test   Loss: 0.85601\n",
      "Test   Accuracy: 58.6%\n",
      "Epoch 7\n",
      "Train  Loss: 0.46463\n",
      "Train  Accuracy: 75.3%\n",
      "Test   Loss: 0.58487\n",
      "Test   Accuracy: 71.1%\n",
      "Epoch 8\n",
      "Train  Loss: 0.33387\n",
      "Train  Accuracy: 86.5%\n",
      "Test   Loss: 0.45445\n",
      "Test   Accuracy: 77.1%\n",
      "Epoch 9\n",
      "Train  Loss: 0.32303\n",
      "Train  Accuracy: 87.7%\n",
      "Test   Loss: 0.45208\n",
      "Test   Accuracy: 78.9%\n",
      "Epoch 10\n",
      "Train  Loss: 0.31797\n",
      "Train  Accuracy: 87.8%\n",
      "Test   Loss: 0.45144\n",
      "Test   Accuracy: 80.7%\n",
      "Epoch 11\n",
      "Train  Loss: 0.47277\n",
      "Train  Accuracy: 74.6%\n",
      "Test   Loss: 0.66623\n",
      "Test   Accuracy: 67.5%\n",
      "Epoch 12\n",
      "Train  Loss: 0.32887\n",
      "Train  Accuracy: 86.7%\n",
      "Test   Loss: 0.48419\n",
      "Test   Accuracy: 76.8%\n",
      "Epoch 13\n",
      "Train  Loss: 0.33205\n",
      "Train  Accuracy: 85.2%\n",
      "Test   Loss: 0.48284\n",
      "Test   Accuracy: 76.8%\n",
      "Epoch 14\n",
      "Train  Loss: 0.30129\n",
      "Train  Accuracy: 87.7%\n",
      "Test   Loss: 0.45273\n",
      "Test   Accuracy: 80.0%\n",
      "Epoch 15\n",
      "Train  Loss: 0.69373\n",
      "Train  Accuracy: 66.1%\n",
      "Test   Loss: 0.84741\n",
      "Test   Accuracy: 60.0%\n",
      "Epoch 16\n",
      "Train  Loss: 0.90043\n",
      "Train  Accuracy: 60.2%\n",
      "Test   Loss: 1.10525\n",
      "Test   Accuracy: 55.4%\n",
      "Epoch 17\n",
      "Train  Loss: 0.31883\n",
      "Train  Accuracy: 86.2%\n",
      "Test   Loss: 0.47711\n",
      "Test   Accuracy: 78.2%\n",
      "Epoch 18\n",
      "Train  Loss: 0.68496\n",
      "Train  Accuracy: 65.2%\n",
      "Test   Loss: 0.87739\n",
      "Test   Accuracy: 59.3%\n",
      "Epoch 19\n",
      "Train  Loss: 0.33017\n",
      "Train  Accuracy: 85.9%\n",
      "Test   Loss: 0.52678\n",
      "Test   Accuracy: 76.8%\n",
      "Epoch 20\n",
      "Train  Loss: 0.29584\n",
      "Train  Accuracy: 88.6%\n",
      "Test   Loss: 0.43470\n",
      "Test   Accuracy: 80.7%\n",
      "Epoch 21\n",
      "Train  Loss: 0.29099\n",
      "Train  Accuracy: 89.4%\n",
      "Test   Loss: 0.45623\n",
      "Test   Accuracy: 79.3%\n",
      "Epoch 22\n",
      "Train  Loss: 0.79201\n",
      "Train  Accuracy: 63.3%\n",
      "Test   Loss: 0.95356\n",
      "Test   Accuracy: 58.6%\n",
      "Epoch 23\n",
      "Train  Loss: 0.35573\n",
      "Train  Accuracy: 83.0%\n",
      "Test   Loss: 0.53456\n",
      "Test   Accuracy: 71.8%\n",
      "Epoch 24\n",
      "Train  Loss: 0.29094\n",
      "Train  Accuracy: 89.9%\n",
      "Test   Loss: 0.43990\n",
      "Test   Accuracy: 79.3%\n",
      "Epoch 25\n",
      "Train  Loss: 0.29328\n",
      "Train  Accuracy: 89.1%\n",
      "Test   Loss: 0.43468\n",
      "Test   Accuracy: 79.6%\n",
      "Epoch 26\n",
      "Train  Loss: 0.29041\n",
      "Train  Accuracy: 88.7%\n",
      "Test   Loss: 0.44635\n",
      "Test   Accuracy: 79.6%\n",
      "Epoch 27\n",
      "Train  Loss: 0.55998\n",
      "Train  Accuracy: 69.6%\n",
      "Test   Loss: 0.73803\n",
      "Test   Accuracy: 63.2%\n",
      "Epoch 28\n",
      "Train  Loss: 0.35123\n",
      "Train  Accuracy: 83.4%\n",
      "Test   Loss: 0.51747\n",
      "Test   Accuracy: 72.9%\n",
      "Epoch 29\n",
      "Train  Loss: 1.69520\n",
      "Train  Accuracy: 54.5%\n",
      "Test   Loss: 1.91036\n",
      "Test   Accuracy: 52.1%\n",
      "Epoch 30\n",
      "Train  Loss: 0.29160\n",
      "Train  Accuracy: 88.5%\n",
      "Test   Loss: 0.43362\n",
      "Test   Accuracy: 81.1%\n",
      "Epoch 31\n",
      "Train  Loss: 1.02346\n",
      "Train  Accuracy: 57.9%\n",
      "Test   Loss: 1.20691\n",
      "Test   Accuracy: 53.2%\n",
      "Epoch 32\n",
      "Train  Loss: 0.28926\n",
      "Train  Accuracy: 88.9%\n",
      "Test   Loss: 0.44636\n",
      "Test   Accuracy: 78.9%\n",
      "Epoch 33\n",
      "Train  Loss: 0.28356\n",
      "Train  Accuracy: 89.3%\n",
      "Test   Loss: 0.45554\n",
      "Test   Accuracy: 77.1%\n",
      "Epoch 34\n",
      "Train  Loss: 0.89516\n",
      "Train  Accuracy: 59.5%\n",
      "Test   Loss: 1.08729\n",
      "Test   Accuracy: 53.9%\n",
      "Epoch 35\n",
      "Train  Loss: 0.63140\n",
      "Train  Accuracy: 67.3%\n",
      "Test   Loss: 0.82585\n",
      "Test   Accuracy: 60.0%\n",
      "Epoch 36\n",
      "Train  Loss: 0.33272\n",
      "Train  Accuracy: 85.7%\n",
      "Test   Loss: 0.52124\n",
      "Test   Accuracy: 76.1%\n",
      "Epoch 37\n",
      "Train  Loss: 0.90068\n",
      "Train  Accuracy: 59.7%\n",
      "Test   Loss: 1.10443\n",
      "Test   Accuracy: 53.9%\n",
      "Epoch 38\n",
      "Train  Loss: 0.41728\n",
      "Train  Accuracy: 79.1%\n",
      "Test   Loss: 0.59645\n",
      "Test   Accuracy: 72.1%\n",
      "Epoch 39\n",
      "Train  Loss: 0.29578\n",
      "Train  Accuracy: 89.3%\n",
      "Test   Loss: 0.46959\n",
      "Test   Accuracy: 78.6%\n",
      "Epoch 40\n",
      "Train  Loss: 0.28477\n",
      "Train  Accuracy: 89.8%\n",
      "Test   Loss: 0.47290\n",
      "Test   Accuracy: 77.1%\n",
      "Epoch 41\n",
      "Train  Loss: 0.79603\n",
      "Train  Accuracy: 61.6%\n",
      "Test   Loss: 1.00241\n",
      "Test   Accuracy: 56.4%\n",
      "Epoch 42\n",
      "Train  Loss: 0.29634\n",
      "Train  Accuracy: 88.7%\n",
      "Test   Loss: 0.47950\n",
      "Test   Accuracy: 79.3%\n",
      "Epoch 43\n",
      "Train  Loss: 0.29162\n",
      "Train  Accuracy: 88.5%\n",
      "Test   Loss: 0.47160\n",
      "Test   Accuracy: 76.4%\n",
      "Epoch 44\n",
      "Train  Loss: 0.74748\n",
      "Train  Accuracy: 64.7%\n",
      "Test   Loss: 0.97208\n",
      "Test   Accuracy: 57.5%\n",
      "Epoch 45\n",
      "Train  Loss: 0.32037\n",
      "Train  Accuracy: 85.1%\n",
      "Test   Loss: 0.52109\n",
      "Test   Accuracy: 75.0%\n",
      "Epoch 46\n",
      "Train  Loss: 0.28124\n",
      "Train  Accuracy: 89.3%\n",
      "Test   Loss: 0.49289\n",
      "Test   Accuracy: 78.6%\n",
      "Epoch 47\n",
      "Train  Loss: 0.38134\n",
      "Train  Accuracy: 80.9%\n",
      "Test   Loss: 0.59058\n",
      "Test   Accuracy: 71.8%\n",
      "Epoch 48\n",
      "Train  Loss: 0.57638\n",
      "Train  Accuracy: 70.3%\n",
      "Test   Loss: 0.79985\n",
      "Test   Accuracy: 63.2%\n",
      "Epoch 49\n",
      "Train  Loss: 1.44346\n",
      "Train  Accuracy: 53.6%\n",
      "Test   Loss: 1.70621\n",
      "Test   Accuracy: 50.4%\n"
     ]
    }
   ],
   "source": [
    "from torch import optim\n",
    "from torch import nn\n",
    "from braindecode.datautil.signal_target import SignalAndTarget\n",
    "\n",
    "# define a number of train/test trials\n",
    "#nb_train_trials = int(np.floor(7/8*X.shape[0]))\n",
    "classifier.model.conv_classifier = nn.Conv2d(5, 2,(116, 1), bias=True).cuda()\n",
    "\n",
    "# split the dataset\n",
    "#train_set = SignalAndTarget(X[:nb_train_trials], y=y[:nb_train_trials]) # confound, sets are mixed again\n",
    "#test_set = SignalAndTarget(X[nb_train_trials:], y=y[nb_train_trials:])\n",
    "train_set = classifier.train_set\n",
    "test_set = classifier.test_set # that's the fix, but need to update classifier\n",
    "\n",
    "classifier.optimizer = optim.Adam(classifier.model.parameters())\n",
    "\n",
    "nbIter = 50\n",
    "\n",
    "# array that tracks results\n",
    "classifier.loss_rec = np.zeros((nbIter,2))\n",
    "classifier.accuracy_rec = np.zeros((nbIter,2))\n",
    "\n",
    "# run all epoch\n",
    "for i_epoch in range(nbIter):\n",
    "\n",
    "    classifier._batchTrain(i_epoch, train_set)\n",
    "    classifier._evalTraining(i_epoch, train_set, test_set)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 4879
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 279903,
     "status": "ok",
     "timestamp": 1544141691683,
     "user": {
      "displayName": "TheAtom2626",
      "photoUrl": "",
      "userId": "00378881698832173059"
     },
     "user_tz": 300
    },
    "id": "xHpKkopr2iFS",
    "outputId": "fb8b8a13-cdad-48c0-abbb-3ea5cdbb8f82"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--2018-12-07 00:14:15--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S01T.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S01T.mat [following]\n",
      "--2018-12-07 00:14:15--  https://lampx.tugraz.at/~bci/database/002-2014/S01T.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 39794870 (38M)\n",
      "Saving to: ‘S01T.mat’\n",
      "\n",
      "S01T.mat            100%[===================>]  37.95M  6.84MB/s    in 12s     \n",
      "\n",
      "2018-12-07 00:14:28 (3.27 MB/s) - ‘S01T.mat’ saved [39794870/39794870]\n",
      "\n",
      "--2018-12-07 00:14:29--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S01E.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S01E.mat [following]\n",
      "--2018-12-07 00:14:29--  https://lampx.tugraz.at/~bci/database/002-2014/S01E.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 23769588 (23M)\n",
      "Saving to: ‘S01E.mat’\n",
      "\n",
      "S01E.mat            100%[===================>]  22.67M  3.95MB/s    in 8.7s    \n",
      "\n",
      "2018-12-07 00:14:39 (2.61 MB/s) - ‘S01E.mat’ saved [23769588/23769588]\n",
      "\n",
      "mkdir: cannot create directory ‘BBCIData’: File exists\n",
      "\n",
      "(60, 15, 3584)\n",
      "(60,)\n",
      "Epoch 0\n",
      "Train  Loss: 0.59035\n",
      "Train  Accuracy: 63.5%\n",
      "Test   Loss: 0.71795\n",
      "Test   Accuracy: 50.0%\n",
      "Epoch 1\n",
      "Train  Loss: 0.53741\n",
      "Train  Accuracy: 69.2%\n",
      "Test   Loss: 0.69791\n",
      "Test   Accuracy: 62.5%\n",
      "Epoch 2\n",
      "Train  Loss: 0.48028\n",
      "Train  Accuracy: 82.7%\n",
      "Test   Loss: 0.67063\n",
      "Test   Accuracy: 62.5%\n",
      "Epoch 3\n",
      "Train  Loss: 0.42742\n",
      "Train  Accuracy: 90.4%\n",
      "Test   Loss: 0.64467\n",
      "Test   Accuracy: 75.0%\n",
      "Epoch 4\n",
      "Train  Loss: 0.38158\n",
      "Train  Accuracy: 92.3%\n",
      "Test   Loss: 0.61856\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 5\n",
      "Train  Loss: 0.34126\n",
      "Train  Accuracy: 94.2%\n",
      "Test   Loss: 0.58863\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 6\n",
      "Train  Loss: 0.30431\n",
      "Train  Accuracy: 94.2%\n",
      "Test   Loss: 0.55712\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 7\n",
      "Train  Loss: 0.27281\n",
      "Train  Accuracy: 96.2%\n",
      "Test   Loss: 0.53117\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 8\n",
      "Train  Loss: 0.24420\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.50117\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 9\n",
      "Train  Loss: 0.22009\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.47334\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 10\n",
      "Train  Loss: 0.19978\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.44829\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 11\n",
      "Train  Loss: 0.18170\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.42519\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 12\n",
      "Train  Loss: 0.16582\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.40238\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 13\n",
      "Train  Loss: 0.15176\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.38288\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 14\n",
      "Train  Loss: 0.13941\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.36684\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 15\n",
      "Train  Loss: 0.12825\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.35460\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 16\n",
      "Train  Loss: 0.11822\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.34499\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 17\n",
      "Train  Loss: 0.10870\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.33678\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 18\n",
      "Train  Loss: 0.10051\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.32920\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 19\n",
      "Train  Loss: 0.09312\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.32177\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 20\n",
      "Train  Loss: 0.08638\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.31344\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 21\n",
      "Train  Loss: 0.08014\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.30799\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 22\n",
      "Train  Loss: 0.07451\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.30423\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 23\n",
      "Train  Loss: 0.06921\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.29714\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 24\n",
      "Train  Loss: 0.06443\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.29052\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 25\n",
      "Train  Loss: 0.06031\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.28300\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 26\n",
      "Train  Loss: 0.05658\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.27913\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 27\n",
      "Train  Loss: 0.05328\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.27572\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 28\n",
      "Train  Loss: 0.05030\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.27514\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 29\n",
      "Train  Loss: 0.04759\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.27249\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 30\n",
      "Train  Loss: 0.04497\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.26947\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 31\n",
      "Train  Loss: 0.04251\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.26470\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 32\n",
      "Train  Loss: 0.04012\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.25948\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 33\n",
      "Train  Loss: 0.03803\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.25503\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 34\n",
      "Train  Loss: 0.03593\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.25090\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 35\n",
      "Train  Loss: 0.03400\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.24655\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 36\n",
      "Train  Loss: 0.03225\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.24253\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 37\n",
      "Train  Loss: 0.03067\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.23928\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 38\n",
      "Train  Loss: 0.02915\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.23697\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 39\n",
      "Train  Loss: 0.02792\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.23510\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 40\n",
      "Train  Loss: 0.02682\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.23309\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 41\n",
      "Train  Loss: 0.02554\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.22865\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 42\n",
      "Train  Loss: 0.02444\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.22469\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 43\n",
      "Train  Loss: 0.02354\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.22113\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 44\n",
      "Train  Loss: 0.02257\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.21919\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 45\n",
      "Train  Loss: 0.02160\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.21884\n",
      "Test   Accuracy: 100.0%\n",
      "Epoch 46\n",
      "Train  Loss: 0.02074\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.21870\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 47\n",
      "Train  Loss: 0.01996\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.21850\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 48\n",
      "Train  Loss: 0.01929\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.21899\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 49\n",
      "Train  Loss: 0.01867\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.21831\n",
      "Test   Accuracy: 87.5%\n"
     ]
    }
   ],
   "source": [
    "from torch import optim\n",
    "from torch import nn\n",
    "from braindecode.datautil.signal_target import SignalAndTarget\n",
    "\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S02T.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S02E.mat\n",
    "!mkdir BBCIData\n",
    "!mv *.mat BBCIData\n",
    "\n",
    "\n",
    "\"\"\"\n",
    "Now, let's load data.\n",
    "\n",
    "We read the file for the desired subject, and parse the data to extract:\n",
    "- samplingRate\n",
    "- trialLength\n",
    "- X, a M x N x K matrix, which stands for trial x chan x samples\n",
    "    - the actual values are 160 x 15 x 2560\n",
    "- y, a M vector containing the labels {0,1}\n",
    "\n",
    "ref: Dataset description: https://lampx.tugraz.at/~bci/database/002-2014/description.pdf\n",
    "\"\"\"\n",
    "\n",
    "folder = \"BBCIData\"\n",
    "datasetID = 1\n",
    "\n",
    "# prepare data containers\n",
    "y_subset = []\n",
    "X_subset = []\n",
    "\n",
    "f = listdir(folder)[datasetID]\n",
    "  \n",
    "# read file\n",
    "d1T = sio.loadmat(folder + \"/\" + f)\n",
    "\n",
    "samplingRate = d1T['data'][0][0][0][0][3][0][0]\n",
    "trialLength = 7*samplingRate\n",
    "\n",
    "# run through all training runs\n",
    "for run in range(len(d1T['data'][0])):\n",
    "    y_subset.append(d1T['data'][0][run][0][0][2][0]) # labels\n",
    "    timestamps = d1T['data'][0][run][0][0][1][0] # timestamps\n",
    "    rawData = d1T['data'][0][run][0][0][0].transpose() # chan x data\n",
    "\n",
    "    # parse out data based on timestamps\n",
    "    for start in timestamps:\n",
    "        end = start + trialLength\n",
    "        X_subset.append(rawData[:,start:end]) #15 x 2560\n",
    "\n",
    "del rawData\n",
    "del d1T\n",
    "\n",
    "# arrange data into num7py arrays\n",
    "# also torch expect float32 for samples\n",
    "# and int64 for labels {0,1}\n",
    "X_subset = np.array(X_subset).astype(np.float32)\n",
    "y_subset = (np.array(y_subset).flatten()-1).astype(np.int64)\n",
    "print()\n",
    "print(X_subset.shape)\n",
    "print(y_subset.shape)\n",
    "\n",
    "\n",
    "# rand permute dataset\n",
    "idx = np.random.permutation(X_subset.shape[0])\n",
    "\n",
    "X_subset = X_subset[idx,:,:]\n",
    "y_subset = y_subset[idx]\n",
    "\n",
    "\n",
    "# define a number of train/test trials\n",
    "nb_train_trials = int(np.floor(7/8*X_subset.shape[0]))\n",
    "\n",
    "# split the dataset\n",
    "train_set_subset = SignalAndTarget(X_subset[:nb_train_trials], y=y_subset[:nb_train_trials])\n",
    "test_set_subset = SignalAndTarget(X_subset[nb_train_trials:], y=y_subset[nb_train_trials:])\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "from torch import optim\n",
    "from torch import nn\n",
    "from braindecode.datautil.signal_target import SignalAndTarget\n",
    "\n",
    "# define a number of train/test trials\n",
    "classifier.model.conv_classifier = nn.Conv2d(5, 2,(116, 1), bias=True).cuda()\n",
    "\n",
    "classifier.optimizer = optim.Adam(classifier.model.parameters())\n",
    "\n",
    "nbIter = 50\n",
    "\n",
    "# array that tracks results\n",
    "classifier.loss_rec = np.zeros((nbIter,2))\n",
    "classifier.accuracy_rec = np.zeros((nbIter,2))\n",
    "\n",
    "# run all epoch\n",
    "for i_epoch in range(nbIter):\n",
    "\n",
    "    classifier._batchTrain(i_epoch, train_set_subset)\n",
    "    classifier._evalTraining(i_epoch, train_set_subset, test_set_subset)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 4267
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 6520,
     "status": "ok",
     "timestamp": 1544141380740,
     "user": {
      "displayName": "TheAtom2626",
      "photoUrl": "",
      "userId": "00378881698832173059"
     },
     "user_tz": 300
    },
    "id": "stBQvDoj19dR",
    "outputId": "8e83a16e-1286-4d9c-8ac1-4ad8bf486892"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 0\n",
      "Train  Loss: 0.01411\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.45631\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 1\n",
      "Train  Loss: 0.01369\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.45678\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 2\n",
      "Train  Loss: 0.01326\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.45545\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 3\n",
      "Train  Loss: 0.01289\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.45607\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 4\n",
      "Train  Loss: 0.01253\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.45559\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 5\n",
      "Train  Loss: 0.01216\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.45258\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 6\n",
      "Train  Loss: 0.01182\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.44866\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 7\n",
      "Train  Loss: 0.01151\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.44688\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 8\n",
      "Train  Loss: 0.01122\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.44529\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 9\n",
      "Train  Loss: 0.01096\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.44381\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 10\n",
      "Train  Loss: 0.01070\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.44116\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 11\n",
      "Train  Loss: 0.01046\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.43645\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 12\n",
      "Train  Loss: 0.01023\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.43478\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 13\n",
      "Train  Loss: 0.01001\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.43866\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 14\n",
      "Train  Loss: 0.00976\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.44634\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 15\n",
      "Train  Loss: 0.00949\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.45189\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 16\n",
      "Train  Loss: 0.00920\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.45601\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 17\n",
      "Train  Loss: 0.00890\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.45772\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 18\n",
      "Train  Loss: 0.00861\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.45853\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 19\n",
      "Train  Loss: 0.00832\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.45800\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 20\n",
      "Train  Loss: 0.00806\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.45809\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 21\n",
      "Train  Loss: 0.00780\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.45934\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 22\n",
      "Train  Loss: 0.00757\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.46104\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 23\n",
      "Train  Loss: 0.00733\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.45554\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 24\n",
      "Train  Loss: 0.00714\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.45005\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 25\n",
      "Train  Loss: 0.00699\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.44585\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 26\n",
      "Train  Loss: 0.00684\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.44494\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 27\n",
      "Train  Loss: 0.00670\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.44465\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 28\n",
      "Train  Loss: 0.00656\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.44659\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 29\n",
      "Train  Loss: 0.00643\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.45250\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 30\n",
      "Train  Loss: 0.00634\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.45858\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 31\n",
      "Train  Loss: 0.00624\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.46391\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 32\n",
      "Train  Loss: 0.00615\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.46770\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 33\n",
      "Train  Loss: 0.00602\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.47048\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 34\n",
      "Train  Loss: 0.00588\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.47247\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 35\n",
      "Train  Loss: 0.00576\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.47522\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 36\n",
      "Train  Loss: 0.00564\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.47548\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 37\n",
      "Train  Loss: 0.00550\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.47629\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 38\n",
      "Train  Loss: 0.00538\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.48025\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 39\n",
      "Train  Loss: 0.00528\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.48644\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 40\n",
      "Train  Loss: 0.00518\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.49224\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 41\n",
      "Train  Loss: 0.00509\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.49633\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 42\n",
      "Train  Loss: 0.00504\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.50633\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 43\n",
      "Train  Loss: 0.00497\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.51250\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 44\n",
      "Train  Loss: 0.00488\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.51696\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 45\n",
      "Train  Loss: 0.00477\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.51926\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 46\n",
      "Train  Loss: 0.00465\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.51979\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 47\n",
      "Train  Loss: 0.00452\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.51986\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 48\n",
      "Train  Loss: 0.00438\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.51918\n",
      "Test   Accuracy: 87.5%\n",
      "Epoch 49\n",
      "Train  Loss: 0.00424\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 0.51738\n",
      "Test   Accuracy: 87.5%\n"
     ]
    }
   ],
   "source": [
    "nbIter = 50\n",
    "\n",
    "# array that tracks results\n",
    "classifier.loss_rec = np.zeros((nbIter,2))\n",
    "classifier.accuracy_rec = np.zeros((nbIter,2))\n",
    "\n",
    "# run all epoch\n",
    "for i_epoch in range(nbIter):\n",
    "\n",
    "    classifier._batchTrain(i_epoch, train_set_subset)\n",
    "    classifier._evalTraining(i_epoch, train_set_subset, test_set_subset)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 612
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 20741,
     "status": "ok",
     "timestamp": 1539306170116,
     "user": {
      "displayName": "TheAtom2626",
      "photoUrl": "",
      "userId": "00378881698832173059"
     },
     "user_tz": 240
    },
    "id": "SeSZLoSi0yE7",
    "outputId": "d031112f-ff67-4502-add7-68259c8848d2"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--2018-10-12 01:02:30--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S01T.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S01T.mat [following]\n",
      "--2018-10-12 01:02:30--  https://lampx.tugraz.at/~bci/database/002-2014/S01T.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 39794870 (38M)\n",
      "Saving to: ‘S01T.mat’\n",
      "\n",
      "S01T.mat            100%[===================>]  37.95M  10.4MB/s    in 5.9s    \n",
      "\n",
      "2018-10-12 01:02:37 (6.44 MB/s) - ‘S01T.mat’ saved [39794870/39794870]\n",
      "\n",
      "--2018-10-12 01:02:38--  http://bnci-horizon-2020.eu/database/data-sets/002-2014/S01E.mat\n",
      "Resolving bnci-horizon-2020.eu (bnci-horizon-2020.eu)... 91.227.204.35\n",
      "Connecting to bnci-horizon-2020.eu (bnci-horizon-2020.eu)|91.227.204.35|:80... connected.\n",
      "HTTP request sent, awaiting response... 302 Found\n",
      "Location: https://lampx.tugraz.at/~bci/database/002-2014/S01E.mat [following]\n",
      "--2018-10-12 01:02:39--  https://lampx.tugraz.at/~bci/database/002-2014/S01E.mat\n",
      "Resolving lampx.tugraz.at (lampx.tugraz.at)... 129.27.124.207\n",
      "Connecting to lampx.tugraz.at (lampx.tugraz.at)|129.27.124.207|:443... connected.\n",
      "HTTP request sent, awaiting response... 200 OK\n",
      "Length: 23769588 (23M)\n",
      "Saving to: ‘S01E.mat’\n",
      "\n",
      "S01E.mat            100%[===================>]  22.67M  5.50MB/s    in 5.1s    \n",
      "\n",
      "2018-10-12 01:02:44 (4.43 MB/s) - ‘S01E.mat’ saved [23769588/23769588]\n",
      "\n",
      "\n",
      "(100, 15, 3584)\n",
      "(100,)\n"
     ]
    }
   ],
   "source": [
    "\"\"\"\n",
    "#from brainDecodeSKLearnWrapper.ShallowFBCSPNet_SpecializedTrainer import ShallowFBCSPNet_SpecializedTrainer\n",
    "\n",
    "\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S01T.mat\n",
    "!wget http://bnci-horizon-2020.eu/database/data-sets/002-2014/S01E.mat\n",
    "!mkdir BBCIData\n",
    "!mv *.mat BBCIData\n",
    "\n",
    "\n",
    "\"\"\"\n",
    "Now, let's load data.\n",
    "\n",
    "We read the file for the desired subject, and parse the data to extract:\n",
    "- samplingRate\n",
    "- trialLength\n",
    "- X, a M x N x K matrix, which stands for trial x chan x samples\n",
    "    - the actual values are 160 x 15 x 2560\n",
    "- y, a M vector containing the labels {0,1}\n",
    "\n",
    "ref: Dataset description: https://lampx.tugraz.at/~bci/database/002-2014/description.pdf\n",
    "\"\"\"\n",
    "\n",
    "folder = \"BBCIData\"\n",
    "datasetID = 1\n",
    "\n",
    "# prepare data containers\n",
    "y = []\n",
    "X = []\n",
    "\n",
    "f = listdir(folder)[datasetID]\n",
    "  \n",
    "# read file\n",
    "d1T = sio.loadmat(folder + \"/\" + f)\n",
    "\n",
    "samplingRate = d1T['data'][0][0][0][0][3][0][0]\n",
    "trialLength = 7*samplingRate\n",
    "\n",
    "# run through all training runs\n",
    "for run in range(len(d1T['data'][0])):\n",
    "    y.append(d1T['data'][0][run][0][0][2][0]) # labels\n",
    "    timestamps = d1T['data'][0][run][0][0][1][0] # timestamps\n",
    "    rawData = d1T['data'][0][run][0][0][0].transpose() # chan x data\n",
    "\n",
    "    # parse out data based on timestamps\n",
    "    for start in timestamps:\n",
    "        end = start + trialLength\n",
    "        X.append(rawData[:,start:end]) #15 x 2560\n",
    "\n",
    "del rawData\n",
    "del d1T\n",
    "\n",
    "# arrange data into num7py arrays\n",
    "# also torch expect float32 for samples\n",
    "# and int64 for labels {0,1}\n",
    "X = np.array(X).astype(np.float32)\n",
    "y = (np.array(y).flatten()-1).astype(np.int64)\n",
    "print()\n",
    "print(X.shape)\n",
    "print(y.shape)\n",
    "\n",
    "\n",
    "# rand permute dataset\n",
    "idx = np.random.permutation(X.shape[0])\n",
    "\n",
    "X = X[idx,:,:]\n",
    "y = y[idx]\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "#specializedClassifier = ShallowFBCSPNet_SpecializedTrainer(network=classifier.model)\n",
    "#specializedClassifier.lr = 0.01\n",
    "#specializedClassifier.configure(initial_lr=0.01)\n",
    "#specializedClassifier.fit(X,y)\n",
    "\n",
    "\n",
    "\"\"\"\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 13634
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 31530,
     "status": "ok",
     "timestamp": 1539306718806,
     "user": {
      "displayName": "TheAtom2626",
      "photoUrl": "",
      "userId": "00378881698832173059"
     },
     "user_tz": 240
    },
    "id": "qwZGsiv2S653",
    "outputId": "0a10306c-ef39-454d-8174-96ca8debab0a"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Epoch 0\n",
      "Train  Loss: 0.40867\n",
      "Train  Accuracy: 79.3%\n",
      "Test   Loss: 1.06219\n",
      "Test   Accuracy: 38.5%\n",
      "Epoch 1\n",
      "Train  Loss: 0.24243\n",
      "Train  Accuracy: 97.7%\n",
      "Test   Loss: 1.22067\n",
      "Test   Accuracy: 30.8%\n",
      "Epoch 2\n",
      "Train  Loss: 0.15374\n",
      "Train  Accuracy: 98.9%\n",
      "Test   Loss: 1.23056\n",
      "Test   Accuracy: 46.2%\n",
      "Epoch 3\n",
      "Train  Loss: 0.10635\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.24592\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 4\n",
      "Train  Loss: 0.07798\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.24732\n",
      "Test   Accuracy: 46.2%\n",
      "Epoch 5\n",
      "Train  Loss: 0.05839\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.29423\n",
      "Test   Accuracy: 46.2%\n",
      "Epoch 6\n",
      "Train  Loss: 0.04658\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.35518\n",
      "Test   Accuracy: 46.2%\n",
      "Epoch 7\n",
      "Train  Loss: 0.03919\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.43166\n",
      "Test   Accuracy: 46.2%\n",
      "Epoch 8\n",
      "Train  Loss: 0.03243\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.48398\n",
      "Test   Accuracy: 46.2%\n",
      "Epoch 9\n",
      "Train  Loss: 0.02648\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.53610\n",
      "Test   Accuracy: 46.2%\n",
      "Epoch 10\n",
      "Train  Loss: 0.02174\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.57515\n",
      "Test   Accuracy: 46.2%\n",
      "Epoch 11\n",
      "Train  Loss: 0.01962\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.59625\n",
      "Test   Accuracy: 46.2%\n",
      "Epoch 12\n",
      "Train  Loss: 0.01830\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.60808\n",
      "Test   Accuracy: 46.2%\n",
      "Epoch 13\n",
      "Train  Loss: 0.01781\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.61399\n",
      "Test   Accuracy: 46.2%\n",
      "Epoch 14\n",
      "Train  Loss: 0.01724\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.62325\n",
      "Test   Accuracy: 46.2%\n",
      "Epoch 15\n",
      "Train  Loss: 0.01621\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.62646\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 16\n",
      "Train  Loss: 0.01563\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.64470\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 17\n",
      "Train  Loss: 0.01386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.67457\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 18\n",
      "Train  Loss: 0.01249\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.72219\n",
      "Test   Accuracy: 46.2%\n",
      "Epoch 19\n",
      "Train  Loss: 0.01077\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.75488\n",
      "Test   Accuracy: 46.2%\n",
      "Epoch 20\n",
      "Train  Loss: 0.00932\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.76248\n",
      "Test   Accuracy: 46.2%\n",
      "Epoch 21\n",
      "Train  Loss: 0.00881\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.77271\n",
      "Test   Accuracy: 46.2%\n",
      "Epoch 22\n",
      "Train  Loss: 0.00799\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.81269\n",
      "Test   Accuracy: 46.2%\n",
      "Epoch 23\n",
      "Train  Loss: 0.00725\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.86557\n",
      "Test   Accuracy: 46.2%\n",
      "Epoch 24\n",
      "Train  Loss: 0.00632\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.97068\n",
      "Test   Accuracy: 46.2%\n",
      "Epoch 25\n",
      "Train  Loss: 0.00730\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.08166\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 26\n",
      "Train  Loss: 0.00780\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.07707\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 27\n",
      "Train  Loss: 0.00639\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.00143\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 28\n",
      "Train  Loss: 0.00608\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.96633\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 29\n",
      "Train  Loss: 0.00571\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.94421\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 30\n",
      "Train  Loss: 0.00569\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.94688\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 31\n",
      "Train  Loss: 0.00567\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.94852\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 32\n",
      "Train  Loss: 0.00562\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.95141\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 33\n",
      "Train  Loss: 0.00558\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.95666\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 34\n",
      "Train  Loss: 0.00551\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.96861\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 35\n",
      "Train  Loss: 0.00546\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 1.98547\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 36\n",
      "Train  Loss: 0.00543\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.00147\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 37\n",
      "Train  Loss: 0.00538\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.01262\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 38\n",
      "Train  Loss: 0.00530\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.01655\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 39\n",
      "Train  Loss: 0.00525\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.02344\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 40\n",
      "Train  Loss: 0.00516\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.02964\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 41\n",
      "Train  Loss: 0.00504\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.03204\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 42\n",
      "Train  Loss: 0.00492\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.03074\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 43\n",
      "Train  Loss: 0.00481\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.03596\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 44\n",
      "Train  Loss: 0.00473\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.04009\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 45\n",
      "Train  Loss: 0.00463\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.04249\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 46\n",
      "Train  Loss: 0.00453\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.04992\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 47\n",
      "Train  Loss: 0.00446\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.05741\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 48\n",
      "Train  Loss: 0.00440\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.06373\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 49\n",
      "Train  Loss: 0.00436\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.07039\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 50\n",
      "Train  Loss: 0.00432\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.07497\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 51\n",
      "Train  Loss: 0.00429\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.08456\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 52\n",
      "Train  Loss: 0.00427\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.09127\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 53\n",
      "Train  Loss: 0.00426\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.09950\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 54\n",
      "Train  Loss: 0.00425\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.10576\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 55\n",
      "Train  Loss: 0.00423\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.10707\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 56\n",
      "Train  Loss: 0.00419\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.11180\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 57\n",
      "Train  Loss: 0.00414\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.11794\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 58\n",
      "Train  Loss: 0.00409\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.12871\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 59\n",
      "Train  Loss: 0.00405\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13115\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 60\n",
      "Train  Loss: 0.00405\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13248\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 61\n",
      "Train  Loss: 0.00405\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13286\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 62\n",
      "Train  Loss: 0.00404\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13316\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 63\n",
      "Train  Loss: 0.00404\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13328\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 64\n",
      "Train  Loss: 0.00403\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13382\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 65\n",
      "Train  Loss: 0.00402\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13440\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 66\n",
      "Train  Loss: 0.00402\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13462\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 67\n",
      "Train  Loss: 0.00401\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13428\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 68\n",
      "Train  Loss: 0.00400\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13436\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 69\n",
      "Train  Loss: 0.00400\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13464\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 70\n",
      "Train  Loss: 0.00399\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13525\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 71\n",
      "Train  Loss: 0.00399\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13552\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 72\n",
      "Train  Loss: 0.00399\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13632\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 73\n",
      "Train  Loss: 0.00398\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13719\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 74\n",
      "Train  Loss: 0.00398\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13816\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 75\n",
      "Train  Loss: 0.00398\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13821\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 76\n",
      "Train  Loss: 0.00398\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13820\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 77\n",
      "Train  Loss: 0.00397\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13875\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 78\n",
      "Train  Loss: 0.00396\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13890\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 79\n",
      "Train  Loss: 0.00396\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13842\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 80\n",
      "Train  Loss: 0.00395\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13933\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 81\n",
      "Train  Loss: 0.00394\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.14047\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 82\n",
      "Train  Loss: 0.00393\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.14105\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 83\n",
      "Train  Loss: 0.00393\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.14127\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 84\n",
      "Train  Loss: 0.00392\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.14174\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 85\n",
      "Train  Loss: 0.00391\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.14166\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 86\n",
      "Train  Loss: 0.00390\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.14085\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 87\n",
      "Train  Loss: 0.00390\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13996\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 88\n",
      "Train  Loss: 0.00389\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13915\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 89\n",
      "Train  Loss: 0.00388\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13885\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 90\n",
      "Train  Loss: 0.00387\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13894\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 91\n",
      "Train  Loss: 0.00387\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13896\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 92\n",
      "Train  Loss: 0.00387\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13886\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 93\n",
      "Train  Loss: 0.00387\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13902\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 94\n",
      "Train  Loss: 0.00387\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13901\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 95\n",
      "Train  Loss: 0.00387\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13912\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 96\n",
      "Train  Loss: 0.00387\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13882\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 97\n",
      "Train  Loss: 0.00387\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13943\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 98\n",
      "Train  Loss: 0.00387\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13955\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 99\n",
      "Train  Loss: 0.00387\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13953\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 100\n",
      "Train  Loss: 0.00387\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13966\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 101\n",
      "Train  Loss: 0.00387\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.14003\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 102\n",
      "Train  Loss: 0.00387\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.14016\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 103\n",
      "Train  Loss: 0.00387\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.14000\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 104\n",
      "Train  Loss: 0.00387\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13978\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 105\n",
      "Train  Loss: 0.00387\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13973\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 106\n",
      "Train  Loss: 0.00387\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13930\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 107\n",
      "Train  Loss: 0.00387\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13915\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 108\n",
      "Train  Loss: 0.00387\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13888\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 109\n",
      "Train  Loss: 0.00387\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13888\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 110\n",
      "Train  Loss: 0.00387\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13877\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 111\n",
      "Train  Loss: 0.00387\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13868\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 112\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13817\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 113\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13880\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 114\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13896\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 115\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13874\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 116\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13832\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 117\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13847\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 118\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13856\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 119\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13898\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 120\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13897\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 121\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13901\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 122\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13867\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 123\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13857\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 124\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13831\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 125\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13839\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 126\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13884\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 127\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13885\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 128\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13878\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 129\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13850\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 130\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13828\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 131\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13847\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 132\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13831\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 133\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13801\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 134\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13848\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 135\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13844\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 136\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13881\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 137\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13926\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 138\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13873\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 139\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13843\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 140\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13863\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 141\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13880\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 142\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13882\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 143\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13900\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 144\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13884\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 145\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13905\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 146\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13930\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 147\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13904\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 148\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13910\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 149\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13929\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 150\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13936\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 151\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13922\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 152\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13914\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 153\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13920\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 154\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13917\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 155\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13886\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 156\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13876\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 157\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13872\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 158\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13894\n",
      "Test   Accuracy: 53.8%\n",
      "Epoch 159\n",
      "Train  Loss: 0.00386\n",
      "Train  Accuracy: 100.0%\n",
      "Test   Loss: 2.13930\n",
      "Test   Accuracy: 53.8%\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "ShallowFBCSPNet_SpecializedTrainer(filename=None, network=None)"
      ]
     },
     "execution_count": 36,
     "metadata": {
      "tags": []
     },
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "\n",
    "\n",
    "specializedClassifier = ShallowFBCSPNet_SpecializedTrainer(network=classifier.model)\n",
    "specializedClassifier.lr = 0.01\n",
    "#specializedClassifier.configure(initial_lr=0.01)\n",
    "specializedClassifier.fit(X,y)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "Jm1HclDBt9LB"
   },
   "outputs": [],
   "source": [
    "\n",
    "\n",
    "Subject 1:\n",
    "Train  Loss: 0.01462\n",
    "Train  Accuracy: 100.0%\n",
    "Test   Loss: 0.46110\n",
    "Test   Accuracy: 87.5%\n",
    "\n",
    "  \n",
    "Subject 2:\n",
    "Train  Loss: 0.02354\n",
    "Train  Accuracy: 100.0%\n",
    "Test   Loss: 0.22113\n",
    "Test   Accuracy: 100.0%  \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "colab_type": "text",
    "id": "B7W6H24AJhKl"
   },
   "source": [
    "Best scores so far:\n",
    "\n",
    "Subject 0: 76.9%\n",
    "Subject 1 50.0%\n",
    "\n",
    "\n"
   ]
  }
 ],
 "metadata": {
  "accelerator": "GPU",
  "colab": {
   "collapsed_sections": [],
   "name": "bnci-002-2014-ShallowFBCSPNet-colab.ipynb",
   "provenance": [],
   "version": "0.3.2"
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
